import React, { memo } from 'react';
import cx from 'classnames';
import { bool, oneOf, string } from 'prop-types';

import './Spin.less';

const propTypes = {
  className: string,
  spinning: bool,
  size: oneOf(['small', 'default', 'large']),
};

const defaultProps = {
  className: '',
  spinning: true,
  size: 'default',
};

const Spin = ({ className, spinning, size }) => {
  return (
    <div className={cx(className, { spinning: spinning }, 'spin-container')}>
      <span className={cx('spinner', size)} />
    </div>
  );
};

Spin.propTypes = propTypes;
Spin.defaultProps = defaultProps;
export default memo(Spin);
